package com.iddactylogram.common.enumerate;

public enum CmdEnums {
    ID_GEN(1, "生成ID的命令"),
    HEART(240, "心跳检测的命令"),
    ERR(250, "处理过程中发生了错误");

    private final byte code;
    private final String display;

    CmdEnums(int code, String display) {
        this.code = (byte) code;
        this.display = display;
    }

    public byte getCode() {
        return code;
    }

    public String getDisplay() {
        return display;
    }

    public static CmdEnums resolve(byte cmd) {
        CmdEnums[] values = CmdEnums.values();
        for (CmdEnums cmdEnum : values) {
            if (cmdEnum.code == cmd) {
                return cmdEnum;
            }
        }
        throw new IllegalArgumentException("未被定义的CMD命令，无法被处理！cmd=" + cmd);
    }
}
